#include <iostream>
#include <list>
#include <unordered_map>
#include <unordered_set>
using namespace std;

int main() {
    int n;
    cin >> n;

    list<int> student_list = {1};  // Initialize list with the first student
    unordered_map<int, list<int>::iterator> position_map;
    position_map[1] = student_list.begin();

    // Process insertions
    for (int i = 2; i <= n; ++i) {
        int k, p;
        cin >> k >> p;

        auto it = position_map[k];
        if (p == 1) {
            ++it;  // Insert to the right
        }
        position_map[i] = student_list.insert(it, i);  // Insert and save the iterator
    }

    int m;
    cin >> m;
    unordered_set<int> removed;

    // Process deletions
    for (int i = 0; i < m; ++i) {
        int x;
        cin >> x;
        if (removed.find(x) != removed.end()) {
            continue;  // Skip if already removed
        }
        removed.insert(x);
        student_list.erase(position_map[x]);
    }

    // Output the final sequence
    bool first = true;
    for (int student : student_list) {
        if (!removed.count(student)) {
            if (!first) {
                cout << " ";
            }
            cout << student;
            first = false;
        }
    }
    cout << endl;

    return 0;
}
